;  _____  _____  __  __  __ __  _____      _____  _____  _____  ___  _____  ____
; /   __\/   __\/  \/  \/  |  \/  ___>    /  ___>/     \/  _  \/___\/  _  \/    \ v5
; |  |_ ||   __||  \/  ||  |  ||___  |    |___  ||  |--||  _  <|   ||   __/\-  -/
; \_____/\_____/\__ \__/\_____/<_____/    <_____/\_____/\__|\_/\___/\__/    |__|
;                                      by
;                 _               _ _  __    _
;                | |   ___ _ _ __| | |/ /___| |_____ ____ _ _ _
;                | |__/ _ \ '_/ _` | ' </ -_) / -_) V / _` | '_|
;                |____\___/_| \__,_|_|\_\___|_\___|\_/\__,_|_|
;
;                                      and     _
;                                _ __  __ _ __| |
;                              _| '  \/ _` / _` |_
;                             (_)_|_|_\__,_\__,_(_)
;
;
; PLEASE SET YOUR EMULATOR PROPERTIES AS FOLLOWS:
;
; Emulator File: bluemsx.EXE
; Associated Script File (1): See Below
; Use Short Filenames: YES
; File Types: ROM;DSK;CAS
; (Compressed File Types: ZIP)
;
; This script was written for BlueMSX 2.8.2
; It may work with other versions too......
;
; Emulator Website: http://www.bluemsx.com/
;
; Gamebase Website: http://www.gb64.com/forum/viewtopic.php?t=1297&postdays=0&postorder=asc&start=60
;
; If a Game needs a specific machine use the following keytypes:
; machine=UK  -Default for Disk demos
; machine=Spanish - configured to include an extra 256k mapped memory for some disk demos
; machine=Japanese -Default for Rom demos
; machine=Brazilian -Default for Cas demos
; machine=MSX2
; machine=MSX2braz
; machine=MSX2span - configured to include an extra 2MB MegaRAM for some disk demos
; machine=MSX2jap -  configured to include an extra 2MB MegaRAM for some disk demos
; machine=MSX2french
; machine=MSX2+
; machine=MSX2+
; machine=MSXTurbor
; machine=MSX2-4MB - configured to include an extra 4MB External RAM for some disk demos
; machine=MSX2HB-F700D - Checks scripts folder then copy system ROMs to machine directory
; * only used for Vaxol ROM Hack at the moment *
;
; The following special Rom Types (mappers) are also supported.
;
; ROM Mapper Types
;
; (*)  MSX ROMS   Description
;
; 104     FMDAS       F&M Direct Assembler System rom
; 91     KeyboardMaster      Konami's Keyboard Master rom
; 144     MatraInk      Matra rom with AMD Flash memory
; 19     Mirrored      Mirrored rom (autodetected)
; 20     Normal - start 0x0000     Normal rom (start at 0x0000 - autodetected)
; 42     Normal - start 0x4000     Normal rom (start at 0x4000)
; 39     Normal - start 0x8000     Basic rom (start at 0x8000)
; 109     Playball      Sony Playball rom with digitized speech
; 1     Standard      Standard MSX rom (autodetected)
; 61     Synthesizer      Konami's Synthesizer rom
;
; MSX MEGAROMS
; 6     ASCII16      ASCII16 rom - Example : Xevious
; 9     ASCII16SRAM2      ASCII16 rom with SRAM - Example : Hydlide 2
; 5     ASCII8       ASCII8 rom - Example : Bubble Bobble
; 8     ASCII8SRAM8
;
; Wizardry  ASCII8 rom with SRAM - Examples : Xanadu - Wizardry
; 11     CrossBlaim      Cross Blaim rom
; 7     GameMaster2      Game Master 2 rom (with SRAM)
; 17     GenericKonami      Konami4 variant (for cracked roms)
; 12     HarryFox      Harry Fox - Yuki no Maou hen rom
; 25     HolyQuran      Holy Quran rom (to use with the MSX1/2 Arabic machine)
; 38     KoeiSRAM8
;
; KoeiSRAM32  Koei rom with SRAM - Example : Europe War
; 4     Konami       Konami4 rom (without SCC chip) - Example : The Treasure of Usas
; 3     KonamiSCC      Konami5 rom with SCC chip - Example : Kings Valley 2
; 62     Majutsushi      Hai no Majutsushi rom
; 136     Manbow2      Konami5 rom with SCC chip and Flash memory
; 145     NettouYakyuu      Moero!! Nettou Yakyuu '88 rom with sample player
; 10     R-Type       R-TYPE rom
; 55     SCC       Generic SCC rom
; 15     SCCextended      Extended SD-Snatcher SCC-I rom
; 56     SCC+ or SCCPLUS     Generic SCC-I rom
; 54     SCCmirrored      Mirrored SD-Snatcher SCC-I rom
; 53     SDSnatcher      SD-Snatcher SCC-I rom
; 52     Snatcher      Snatcher SCC-I rom
; 41     SuperLodeRunner     Super Lode Runner rom
; 18     SuperPierrot      Super Pierrot rom
; 14     Zemina126in1      Korean 126-in-1 rom
; 13     Zemina80in1      For three Korean roms : 30-in-1, 64-in-1 and 80-in-1
; 51     Zemina90in1      Korean 90-in-1 rom
;
; MSX SCCPLUSCARTS
; 55     boot : scc      SCC rom games (for cracked roms)
; 56     boot : scc+      SCC-I rom games (for cracked roms)
;
; MSX SYSTEM ROMS
; 140     A1FMModem      Panasonic FS-A1FM modem rom
; 98     BeerIDE      Beer IDE harddisk rom
; 28     Bunsetsu      Bunsetsu rom
; 66     CasPatch      Normal rom + cassette patch
; 21     DiskPatch      Normal rom + disk patch
; 138     ForteII      ForteII arcade bios rom with embedded game
; 16     FMPAC       Panasonic FM-PAC rom (with SRAM and MSX-MUSIC)
; 87     FMPAK       Dutch or Korean MSX-MUSIC rom
; 135     GoudaSCSI      MSX Club Gouda SCSI harddisk rom (Novaxis)
; 40     Halnote      Halnote rom with SRAM
; 64     MB8877A      National-Daewoo disk rom
; 63     Microsol      Microsol disk rom
; 19     Mirrored      Mirrored rom (autodetected)
; 50     MSX-AUDIO      Panasonic MSX-AUDIO rom
; 2     MSX-DOS2      MSX-DOS 2 rom
; 78     MSX-MUSIC      Japanese MSX-MUSIC rom
; 31     National      National rom with SRAM
; 20     Normal - start 0x0000     Normal rom (start at 0x0000)
; 42     Normal - start 0x4000     Normal rom (start at 0x4000)
; 39     Normal - start 0x8000     Basic rom (start at 0x8000)
; 86     Normal - start 0xC000     Standard rom (start at 0xC000)
; 134     NoWind       Nowind USB disk rom
; 110     Obsonet      ObsoNET ethernet cartridge
; 27     Panasonic16      Panasonic FS-A1ST rom with SRAM 16 Kb
; 68     Panasonic32      Panasonic FS-A1GT rom with SRAM 32 Kb
; 139     Panasonic8      Panasonic FS-A1FM rom with SRAM 8 Kb
; 141     PanasonicDram      Panasonic FS-A1ST/GT rom with DRAM
; 142     PanasonicWx16      Panasonic FS-A1WSX/WX rom with SRAM 16 Kb
; 106     SFG-01       Yamaha CX5M music rom - first version
; 105     SFG-05       Yamaha CX5M/CX7M music rom
; 102     SonyHBI-V1      Sony HBI-V1 digitizer rom
; 96     SunriseIDE      Sunrise IDE harddisk rom
; 67     SVI738FDC      Spectravideo SVI-738 disk rom
; 57     TC8566AF      Panasonic disk rom for MSX2 and MSX2+ machines
; 143     TC8566AFTR      Panasonic disk rom for MSXturboR machines
; 100     VMX80       Microsol 80 column card for MSX1
; 65     WD2793       Philips-Sony disk rom
;
; NON-MSX ROMS
; 66     CasPatch      Normal SVI rom + cassette patch
; 76     Coleco       Normal ColecoVision/Adam rom
; 113     MegaCart      MegaCart(R) rom for ColecoVision/Adam
; 20     Normal - start 0x0000     Normal SVI or Coleco bios rom
; 108     SC3000       Normal SC-3000 rom
; 112     SegaBasic      SC-3000 rom with Sega Basic and RAM
; 107     SF-7000IPL      SF-7000 Initial Program Loader rom
; 94     SG1000       Normal SG-1000 rom
; 95     SG1000Castle      The Castle SG-1000 rom with SRAM
; 74     SVI328CART      Spectravideo SVI-318/328 rom
;
; (*) number used for /romtype1
;
; Examples
; romtype=scc
; romtype=scc+
; romtype=15
; Carts  ROMTYPE NUMBER /mapper cart goes in slot #2
; Disks  ROMTYPE NUMBER /mapper cart goes in slot #1
;---------------------------------------------------------------------------------------
;
; It also supports the following controllers set within the game properties:
; Joystick/Mouse/Light Gun
;
; If games are loaded with a key pressed use the following keytypes which will send the command to the MSXCLDR.EXE:
; Startup=Control
; Startup=Shift
;
;
;---------------------------------------------------------------------------------------------------------------------------
;"blueMSX Default.config" keyboard mappings get overwritten everytime a game is run
;
;The joystick Layout is as follows to use joysticks in port 1 and 2
;If the joystick needs to be set for port 2 then the keymappings will be in reverse order.
;
;
;Keymappings for Games with default joystick in port 1
;joy1-up        =NUMPAD8
;joy1-down      =NUMPAD2
;joy1-left      =NUMPAD4
;joy1-right     =NUMPAD6
;joy1-button1   =NUMPAD0
;joy1-button2   =DECIMAL
;joy2-up        =W
;joy2-down      =S
;joy2-left      =A
;joy2-right     =D
;joy2-button1   =G
;joy2-button2   =H
;
;Keymappings for Games with default joystick in port 2
;joy1-up        =W
;joy1-down      =S
;joy1-left      =A
;joy1-right     =D
;joy1-button1   =G
;joy1-button2   =H
;joy2-up        =NUMPAD8
;joy2-down      =NUMPAD2
;joy2-left      =NUMPAD4
;joy2-right     =NUMPAD6
;joy2-button1   =NUMPAD0
;joy2-button2   =DECIMAL
;
; To use a real joystick overwrite the lines within the Controller Setup Section with the lines below making sure that the semicolon is deleted
;
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-up||J1 UP)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-down||J1 DOWN)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-left||J1 LEFT)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-right||J1 RIGHT)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-button1||J1 BT 1)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-button2||J1 BT 2)
;
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-up||J2 UP)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-down||J2 DOWN)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-left||J2 LEFT)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-right||J2 RIGHT)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-button1||J2 BT 1)
; Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-button2||J2 BT 2)
;
;
;----------------------------------------CONTROLLER SETUP SECTION--------------------------------
;This will check for the controller set within Gamebase
If Control = Mouse
	Set_INI_Value(%emupath%\bluemsx.ini||config||joy1.type||mouse)
ElseIf Control = LightGun
	Set_INI_Value(%emupath%\bluemsx.ini||config||joy1.type||gunstick)
ElseIf Control = JoyPort1
	Set_INI_Value(%emupath%\bluemsx.ini||config||joy1.type||joystick)
	Set_INI_Value(%emupath%\bluemsx.ini||config||joy2.type||joystick)

	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||coleco1-0||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||coleco1-2||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||coleco1-4||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||coleco1-6||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||coleco1-8||"")

	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-up||NUMPAD8)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-down||NUMPAD2)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-left||NUMPAD4)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-right||NUMPAD6)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-button1||NUMPAD0)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-button2||DECIMAL)

	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-up||W)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-down||S)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-left||A)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-right||D)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-button1||G)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-button2||H)
ElseIf Control = JoyPort2
	Set_INI_Value(%emupath%\bluemsx.ini||Config||joy1.type||joystick)
	Set_INI_Value(%emupath%\bluemsx.ini||Config||joy2.type||joystick)

	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||coleco2-0||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||coleco2-2||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||coleco2-4||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||coleco2-6||"")
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||coleco2-8||"")

	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-up||NUMPAD8)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-down||NUMPAD2)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-left||NUMPAD4)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-right||NUMPAD6)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-button1||NUMPAD0)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-2||joy2-button2||DECIMAL)

	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-up||W)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-down||S)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-left||A)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-right||D)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-button1||G)
	Set_INI_Value(%emupath%\Keyboard Config\blueMSX Default.config||Keymapping-1||joy1-button2||H)
End If

;---------------------------------------------------------------------------------------------------------

;resets cmos files. Some games have been known to change the cmos file
;this deletes the cmos files from sram
Run_Program(%dbpath%\scripts\MSXCLDR.exe||-RESET=CLEAR -E="%emupath%\"||WAIT)


;needed for the cassette loader to run correctly
Set_INI_Value(%emupath%\bluemsx.ini||config||emulation.speed||50)

If Key_Startup CONTAINS(Shift)
	Show_Message(Please note you will need to press Shift whilst the game is loading)
End If

;Cas,roms and dsks all have different default Machines - for example the 99% of roms are Japanese
If %gamefile% CONTAINS(*.rom)
	If Key_Machine CONTAINS(UK)
		Add_CLP( /machine "MSX")
	ElseIf Key_Machine CONTAINS(Spanish)
		Add_CLP( /machine "MSX - spanish")
	ElseIf Key_Machine CONTAINS(brazilian)
		Add_CLP( /machine "MSX - Brazilian")
	ElseIf Key_Machine CONTAINS(MSX2)
		Add_CLP( /machine "MSX2")
	ElseIf Key_Machine CONTAINS(MSX2braz)
		Add_CLP( /machine "MSX2 - Brazilian")
	ElseIf Key_Machine CONTAINS(MSX2Span)
		Add_CLP( /machine "MSX2 - Spanish")
	ElseIf Key_Machine CONTAINS(MSX2jap)
		Add_CLP( /machine "MSX2 - Japanese")
	ElseIf Key_Machine CONTAINS(MSX2French)
		Add_CLP( /machine "MSX2 - French")
	ElseIf Key_Machine CONTAINS(MSX2+)
		Add_CLP( /machine "MSX2+")
	ElseIf Key_Machine CONTAINS(MSXTURBOR)
		Add_CLP( /machine "MSXTURBOR")
	ElseIf Key_Machine CONTAINS(MSX2HB-F700D)
		Add_CLP( /machine "MSX2 - Sony HB-F700D")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-CopySysRom="%dbpath%\scripts\MSX2 - Sony HB-F700D\" -E="%emupath%\"||WAIT)
	Else
		Add_CLP( /machine "MSX - Japanese")
	End If

	If Key_romtype CONTAINS(*)
		Add_CLP( /rom1 %gamepathfile% /romtype2 %romtype_value%)
		Run_Emulator()
	Else
		Add_CLP( /rom1 %gamepathfile%)
		Run_Emulator()
	End If

ElseIf %gamefile% CONTAINS(*.dsk)
	Set_INI_Value(%emupath%\bluemsx_history.ini||[config]||diskdrive.defDir||%gamepath%)

	If Key_Machine CONTAINS(Japanese)
		Add_CLP( /machine "MSX - Japanese")
	ElseIf Key_MAchine CONTAINS(Spanish)
		Add_CLP( /machine "MSX - spanish")
		Set_CFG_Item(%emupath%\Machines\MSX - Spanish\config.ini||1 0 0 32 22 "" ""||||)
	ElseIf Key_Machine CONTAINS(brazilian)
		Add_CLP( /machine "MSX - Brazilian")
	ElseIf Key_Machine CONTAINS(MSX2)
		Add_CLP( /machine "MSX2")
	ElseIf Key_Machine CONTAINS(MSX2braz)
		Add_CLP( /machine "MSX2 - Brazilian")
	ElseIf Key_Machine CONTAINS(MSX2Span)
		Set_CFG_Item(%emupath%\Machines\MSX2 - Spanish\config.ini||2 1 0 256 44 "" ""||||)
		Add_CLP( /machine "MSX2 - Spanish")
	ElseIf Key_Machine CONTAINS(MSX2jap)
		Set_CFG_Item(%emupath%\Machines\MSX2 - Japanese\config.ini||2 0 0 256 44 "" ""||||)
		Add_CLP( /machine "MSX2 - Japanese")
	ElseIf Key_Machine CONTAINS(MSX2French)
		Add_CLP( /machine "MSX2 - French")
	ElseIf Key_Machine CONTAINS(MSX2-4mb)
		Add_CLP( /machine "MSX2-4mb")
	ElseIf Key_Machine CONTAINS(MSX2+)
		Add_CLP( /machine "MSX2+")
	ElseIf Key_Machine CONTAINS(MSXTURBOR)
		Add_CLP( /machine "MSXTURBOR")
	ElseIf Key_Machine CONTAINS(MSX2HB-F700D)
		Add_CLP( /machine "MSX2 - Sony HB-F700D")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-CopySysRom="%dbpath%\scripts\MSX2 - Sony HB-F700D\" -E="%emupath%\"||WAIT)
	Else
		Add_CLP( /machine "MSX")
	End If

	If NumGameFiles > 1
		Add_CLP( /diskA %gamepathfile% /diskB %gamepathfile(1)%)
	Else
		Add_CLP( /diskA %gamepathfile%)
	End If

	If Key_romtype CONTAINS(*)
		Add_CLP( /romtype1 %romtype_value%)
	End If

	If Key_romtype2 CONTAINS(*)
		Add_CLP( /romtype2 %romtype2_value%)
	End If





	If Key_Startup CONTAINS(Control)
		If Key_machine CONTAINS(MSX2)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSX2JAP)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSX2FRENCH)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSX2+)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSX2BRAZ)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSX2SPAN)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSXTURBOR)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		ElseIf Key_machine CONTAINS(MSX2HB-F700D)
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-ControlMSX2||NOWAIT)
		Else
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-Control||NOWAIT)
		End If
	End If
	Run_Emulator()

ElseIf %gamefile% CONTAINS(*.cas)
	Set_INI_Value(%emupath%\bluemsx_history.ini||[config]||cassette.defDir||%gamepath%)

	Add_CLP( /cas %gamepathfile%)

	If Key_Machine CONTAINS(casjap)
		Add_CLP( /machine "MSX - Japanese Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=JAP -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=JAP -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=JAP -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=JAP -Command=RUN -Casmachine=Yes||NOWAIT)
		End If

	ElseIf Key_Machine CONTAINS(casuk)
		Add_CLP( /machine "MSX Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -Command=RUN -Casmachine=Yes||NOWAIT)
		End If
	ElseIf Key_Machine CONTAINS(casSpan)
		Add_CLP( /machine "MSX - spanish Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Spanish -E="%emupath%\" -G=""%gamefile%""||WAIT)
		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=SPANISH -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=SPANISH -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=SPANISH -Command=RUN -Casmachine=Yes||NOWAIT)
			Run_Emulator()
		End If
	ElseIf Key_Machine CONTAINS(casMSX2)
		Add_CLP( /machine "MSX2 Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -Command=RUN -Casmachine=Yes||NOWAIT)
		End If
	ElseIf Key_Machine CONTAINS(casMSX2Jap)
		Add_CLP( /machine "MSX2 - Japanese Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -Command=RUN -Casmachine=Yes||NOWAIT)
		End If
	ElseIf Key_Machine CONTAINS(casMSX2Braz)
		Add_CLP( /machine "MSX2 - Brazilian Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -Command=RUN -Casmachine=Yes||NOWAIT)
		End If
	ElseIf Key_Machine CONTAINS(Japanese)
		Add_CLP( /machine "MSX - Japanese")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=JAP -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Jap -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Jap -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Jap -Command=RUN -Casmachine=No||NOWAIT)
			Run_Emulator()
		End If
	ElseIf Key_Machine CONTAINS(UK)
		Add_CLP( /machine "MSX")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=UK -Command=RUN -Casmachine=No||NOWAIT)
			Run_Emulator()
		End If
	ElseIf Key_Machine CONTAINS(Brazilian)
		Add_CLP( /machine "MSX - Brazilian" /diskA %dbpath%\scripts\blank.dsk)
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=BRAZ -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Braz -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Braz -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Braz -Command=RUN -Casmachine=No||NOWAIT)
			Run_Emulator()
		End If
	ElseIf Key_Machine CONTAINS(Spanish)
		Add_CLP( /machine "MSX - spanish")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Spanish -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Spanish -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Spanish -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=Spanish -Command=RUN -Casmachine=No||NOWAIT)
			Run_Emulator()
		End If
	ElseIf Key_Machine CONTAINS(MSX2)
		Add_CLP( /machine "MSX2")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2 -Command=RUN -Casmachine=No||NOWAIT)
		End If
	ElseIf Key_Machine CONTAINS(MSX2Jap)
		Add_CLP( /machine "MSX2 - Japanese")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Jap -Command=RUN -Casmachine=No||NOWAIT)
		End If
	ElseIf Key_Machine CONTAINS(MSX2Braz)
		Add_CLP( /machine "MSX2 - Brazilian")
		;Add_CLP( /diskA %dbpath%\scripts\blank.dsk)

		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -Command=BLOAD -Casmachine=No||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -Command=CLOAD -Casmachine=No||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=MSX2Braz -Command=RUN -Casmachine=No||NOWAIT)
		End If
	Else
		Add_CLP( /machine "MSX - Brazilian Cassette")
		Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=BRAZ -E="%emupath%\" -G=""%gamefile%""||WAIT)

		If Key_cas CONTAINS(bload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=BRAZ -Command=BLOAD -Casmachine=Yes||NOWAIT)
		ElseIf Key_cas CONTAINS(cload)
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=BRAZ -Command=CLOAD -Casmachine=Yes||NOWAIT)
		Else
			Run_Emulator()
			Run_Program(%dbpath%\scripts\MSXCLDR.exe||-M=BRAZ -Command=RUN -Casmachine=Yes||NOWAIT)
		End If
	End If

Else
	Show_Message(This game does not have a supported file extension)

End If

